var KOC = require("koc.common.utils");

var Config = require("../../config");

var DALFactory = require("../../lib/dal/dal-factory");
var CommonUtils = require("../../lib/common-utils");
var FileBuilder = require("../../lib/file-builder");
var Interface_apple = require("../../lib/interface-apple");
var Interface_QCloud_SMS = require("../../lib/interface-qcloud-sms");
var Interface_QCloud = require("../../lib/interface-qcloud");

module.exports = {
  //region Response:客户端响应
  Response: function (req, res) {
    // http://127.0.0.1:12003/mobile/response?equ_c=590c15bb-227b-11e6-9dad-6c92bf203f8f&equ_t=1&app_t=100
    // {"flag":"0","msg":"succeed","mid":1,"auth_c":"f4409750-8a5b-4ba4-839f-b5c8cbe3f5a0"}
    var _Value = {
      Equipment_Code: req.params.equ_c,
      Equipment_Type: req.params.equ_t,
      APP_Type: req.params.app_t
    };
    DALFactory.Business.User_MobileResponse({
      Equipment_Code: _Value.Equipment_Code,
      Equipment_Type: _Value.Equipment_Type,
      APP_Type: _Value.APP_Type,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      switch (retValue.returnObject.Equipment_Type) {
        case 1: //android
          switch (retValue.returnObject.APP_Type) {
            case 100://个人用户版
              _Value.Version = "3.0.3";//2.0.4修改成2.0.9 周永龙
              break;
          }
          break;
        case 2: //android pad
          break;
        case 3: //iphone
          switch (retValue.returnObject.APP_Type) {
            case 300:   //个人用户版
              _Value.Version = "3.0.2";
              break;
          }
          break;
        case 4: //ipad
          break;
      }
      res.jsonp({
        flag: "0",
        msg: "succeed",
        mid: retValue.returnObject.Mobile_ID,
        auth_c: retValue.returnObject.Auth_Code,
        version: _Value.Version,
        download: Config.Common.Virtual_Path.Utils + "service/download/app"
      });
    });
  },
  //endregion
  //region Open:客户端开启
  Open: function (req, res) {
    // http://127.0.0.1:12003/mobile/open?mid=1&app_t=100&s_w=800&s_h=600&os_v=andorid&app_v=1.0.1&app_vc=1&lon=100&la=100&sign=e63b52499b0423597e001c829f4dbe58
    // {"flag":"0","msg":"succeed","data":{"Admin":{"Version":1605142313,"IsLogin":false,"Admin_ID":-1,"Phone":"","RealName":"","IsMaster":false,"RightCode":"","DefaultPW":false},"User":{"Version":1605142313,"IsLogin":false,"User_ID":-1,"NickName":"","RealName":"","Family_ID":null,"IsAnchor":false,"IsFamily":false,"Anchor":{"RoomName":"","RoomWelcome":""},"Family":{"IsMaster":false,"RightCode":""}}}}
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Equipment_Name: decodeURIComponent(KOC.StringUtils.ToString(req.params.equ_n)),
      Screen_Width: req.params.s_w,
      Screen_Height: req.params.s_h,
      OS_Version: decodeURIComponent(KOC.StringUtils.ToString(req.params.os_v)),
      APP_Version: decodeURIComponent(KOC.StringUtils.ToString(req.params.app_v)),
      APP_VersionCode: KOC.StringUtils.ToInt(req.params.app_vc, -1),
      Longitude: KOC.StringUtils.ToFloat(req.params.lon, -1),
      Latitude: KOC.StringUtils.ToFloat(req.params.lat, -1),
      Sign: req.params.sign,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    };
    DALFactory.Business.User_MobileOpen({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Equipment_Name: _Value.Equipment_Name,
      Screen_Width: _Value.Screen_Width,
      Screen_Height: _Value.Screen_Height,
      OS_Version: _Value.OS_Version,
      APP_Version: _Value.APP_Version,
      APP_VersionCode: _Value.APP_VersionCode,
      Longitude: _Value.Longitude,
      Latitude: _Value.Latitude,
      Sign: req.params.sign,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      retValue.returnObject.ImgUserAvatar = Config.Common.Virtual_Path.Utils_CDN + 'service/img/user/avatar/';
      retValue.returnObject.ImgUserCover = Config.Common.Virtual_Path.Utils_CDN + 'service/img/user/cover/';
      res.jsonp({flag: "0", msg: "succeed", data: retValue.returnObject});
    });
  },
  //endregion
  //region Login:用户登录
  Login: function (req, res) {
    // http://127.0.0.1:12003/mobile/login?mid=1&app_t=100&lname=13655548845&lpw=e63b52499b0423597e001c829f4dbe58&sign=e63b52499b0423597e001c829f4dbe58
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      LoginName: req.params.lname,
      Password: req.params.lpw
    };
    DALFactory.Business.User_MobileLogin({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign,
      LoginName: _Value.LoginName,
      Password: _Value.Password,
      SignIn_Type: 2,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: 1,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: "0", msg: "succeed"});
    });
  },
  //endregion
  //region Login_QQ:用户登录绑定(QQ)
  Login_QQ: function (req, res) {
    // http://127.0.0.1:12003/mobile/login-qq?mid=1&app_t=100&qq_id=123&qq_token=aaaaa&qq_expiresin=111&qq_refreshtoken=xxxx&qq_nickname=xxx&qq_sex=1&sign=e63b52499b0423597e001c829f4dbe58
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      OAuth_QQ_ID: req.params.qq_id,
      OAuth_QQ_Token: req.params.qq_token,
      OAuth_QQ_ExpiresIn: req.params.qq_expiresin,
      OAuth_QQ_RefreshToken: req.params.qq_refreshtoken,
      NickName: req.params.qq_nickname,
      Sex: req.params.qq_sex,
      Channel_ID: req.params._cid,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    };
    //移动端昵称判断
    if (_Value.NickName && (_Value.NickName.length < 2 || _Value.NickName.length > 8)) {
      _Value.NickName = null;
    }
    DALFactory.Business.User_MobileLoginQQ({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign,
      OAuth_QQ_ID: _Value.OAuth_QQ_ID,
      OAuth_QQ_Token: _Value.OAuth_QQ_Token,
      OAuth_QQ_ExpiresIn: _Value.OAuth_QQ_ExpiresIn,
      OAuth_QQ_RefreshToken: _Value.OAuth_QQ_RefreshToken,
      NickName: _Value.NickName,
      Sex: _Value.Sex,
      Channel_ID: _Value.Channel_ID,
      Create_IP: _Value.Create_IP
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: "0", msg: "succeed"});
    });
  },
  //endregion
  //region Login_Weibo:用户登录绑定(Weibo)
  Login_Weibo: function (req, res) {
    // http://127.0.0.1:12003/mobile/login-weibo?mid=1&app_t=100&weibo_id=123&weibo_token=aaaaa&weibo_expiresin=111&weibo_nickname=xxx&weibo_sex=1&sign=e63b52499b0423597e001c829f4dbe58
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      OAuth_Weibo_ID: req.params.weibo_id,
      OAuth_Weibo_Token: req.params.weibo_token,
      OAuth_Weibo_ExpiresIn: req.params.weibo_expiresin,
      NickName: req.params.weibo_nickname,
      Sex: req.params.weibo_sex,
      Channel_ID: req.params._cid,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    };
    //移动端昵称判断
    if (_Value.NickName && (_Value.NickName.length < 2 || _Value.NickName.length > 8)) {
      _Value.NickName = null;
    }
    DALFactory.Business.User_MobileLoginWeibo({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign,
      OAuth_Weibo_ID: _Value.OAuth_Weibo_ID,
      OAuth_Weibo_Token: _Value.OAuth_Weibo_Token,
      OAuth_Weibo_ExpiresIn: _Value.OAuth_Weibo_ExpiresIn,
      NickName: _Value.NickName,
      Sex: _Value.Sex,
      Channel_ID: _Value.Channel_ID,
      Create_IP: _Value.Create_IP
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: "0", msg: "succeed"});
    });
  },
  //endregion
  //region Login_Weixin:用户登录绑定(Weixin)
  Login_Weixin: function (req, res) {
    // http://127.0.0.1:12003/mobile/login-weixin?mid=1&app_t=100&weixin_id=123&weixin_uid=123&weixin_token=aaaaa&weixin_expiresin=111&weixin_refreshtoken=xxxx&weixin_nickname=xxx&weixin_sex=1&sign=e63b52499b0423597e001c829f4dbe58
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      OAuth_Weixin_ID: req.params.weixin_id,
      OAuth_Weixin_UNIONID: req.params.weixin_uid,
      OAuth_Weixin_Token: req.params.weixin_token,
      OAuth_Weixin_ExpiresIn: req.params.weixin_expiresin,
      OAuth_Weixin_RefreshToken: req.params.weixin_refreshtoken,
      NickName: req.params.weixin_nickname,
      Sex: req.params.weixin_sex,
      Channel_ID: req.params._cid,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    };
    //移动端昵称判断
    if (_Value.NickName && (_Value.NickName.length < 2 || _Value.NickName.length > 8)) {
      _Value.NickName = null;
    }
    DALFactory.Business.User_MobileLoginWeixin({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign,
      OAuth_Weixin_ID: _Value.OAuth_Weixin_ID,
      OAuth_Weixin_UNIONID: _Value.OAuth_Weixin_UNIONID,
      OAuth_Weixin_Token: _Value.OAuth_Weixin_Token,
      OAuth_Weixin_ExpiresIn: _Value.OAuth_Weixin_ExpiresIn,
      OAuth_Weixin_RefreshToken: _Value.OAuth_Weixin_RefreshToken,
      NickName: _Value.NickName,
      Sex: _Value.Sex,
      Channel_ID: _Value.Channel_ID,
      Create_IP: _Value.Create_IP
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: "0", msg: "succeed"});
    });
  },
  //endregion
  //region Login_Phone:手机注册登录
  Login_Phone: function (req, res) {
    // http://127.0.0.1:2003/mobile/login-phone?mid=1&app_t=100&lname=13655548845&lpw=e63b58&sign=e63b&Phone=18410077168&VerifyCode=51838&Password=111111
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      Phone: req.params.Phone,
      VerifyCode: req.params.VerifyCode,
      Password: req.params.Password,
      Type: req.params.Type,//"SignUp"
      Channel_ID: req.params._cid
    };
    _Value.Phone = KOC.StringUtils.ToInt(_Value.Phone, -1);
    if (_Value.Phone < 0 || !(/^1\d{10}$/).test(_Value.Phone)) {
      res.jsonp({flag: 1, msg: "请输入正确的手机号"});
      return;
    }
    DALFactory.Business.User_MobileLoginPhone({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign,
      OAuth_Phone: _Value.Phone,
      PhoneCode: _Value.VerifyCode,
      Password: _Value.Password,
      Type: _Value.Type,
      Channel_ID: _Value.Channel_ID,
      Create_IP: KOC.StringUtils.GetClientIP(req)
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: 0, msg: "手机注册登录成功"});
    });
  },
  //endregion
  //region Logout:用户退出登录
  Logout: function (req, res) {
    // http://127.0.0.1:12003/mobile/logout?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    DALFactory.Business.User_MobileLogout({
      Mobile_ID: _Value.Mobile_ID,
      APP_Type: _Value.APP_Type,
      Sign: _Value.Sign
    }, function (retValue) {
      if (retValue.hasError) {
        res.jsonp({
          flag: retValue.errorCode,
          msg: retValue.message
        });
        return;
      }
      res.jsonp({flag: "0", msg: "succeed"});
    });
  },
  //endregion
  //region User:用户相关
  User: {
    //region User_Info:用户信息
    User_Info: {
      Info: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-info/info?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //获取用户信息
          function (callback) {
            DALFactory.User.User_Info.Info(_Value.User_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (!retValue.returnObject) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.IsAnchor = retValue.returnObject.IsAnchor;
              _Value.UserInfo = retValue.returnObject;
              callback();
            });
          },
          //获取用户主播信息
          function (callback) {
            if (!_Value.IsAnchor) {
              _Value.Family_ID = -1;
              callback();
              return;
            }
            DALFactory.User.User_Anchor.Info(_Value.User_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (!retValue.returnObject || !KOC.Lodash.includes([0, 1], retValue.returnObject.Status)) {
                //主播信息不存在
                _Value.Family_ID = -1;
                callback();
                return;
              }
              _Value.UserInfo.Anchor_Level = retValue.returnObject.Level;
              _Value.UserInfo.Anchor_Level_Name = retValue.returnObject.Level_Name;
              _Value.UserInfo.Anchor_Level_Next = retValue.returnObject.Level_Next;
              _Value.UserInfo.Anchor_Level_Next_Name = retValue.returnObject.Level_Next_Name;
              _Value.UserInfo.Anchor_EXP_Next = retValue.returnObject.EXP_Next;
              _Value.UserInfo.Anchor_EXP_Difference = retValue.returnObject.EXP_Difference;
              _Value.UserInfo.Family_ID = retValue.returnObject.Family_ID ? retValue.returnObject.Family_ID : -1;
              _Value.Family_ID = _Value.UserInfo.Family_ID;
              callback();
            });
          },
          //获取用户家族信息
          function (callback) {
            if (_Value.Family_ID < 0) {
              callback();
              return;
            }
            DALFactory.User.Family_Info.Info(_Value.Family_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (!retValue.returnObject || !KOC.Lodash.includes([0, 1], retValue.returnObject.Status)) {
                //家族信息不存在
                callback();
                return;
              }
              _Value.UserInfo.Family_Name = retValue.returnObject.Family_Name;
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: 1, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "获取用户信息成功", data: _Value.UserInfo});
        });
      },
      Update: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-info/update?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&NickName=123&QQ=456&Sex=1&Signature=abc
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          NickName: req.params.NickName,
          Signature: req.params.Signature,
          Sex: KOC.StringUtils.ToIntPositive(req.params.Sex)
        };
        if (!KOC.Lodash.includes([1, 2], _Value.Sex)) {
          res.jsonp({flag: 1, msg: "性别错误"});
          return;
        }
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //修改用户信息
          function (callback) {
            DALFactory.User.User_Info.Update({
              NickName: _Value.NickName,
              Signature: _Value.Signature,
              Sex: _Value.Sex,
              User_ID: _Value.User_ID
            }, function (retValue) {
              if (retValue.hasError) {
                retValue.message = "修改用户信息出错,该昵称已被占用";
                callback(retValue);
                return;
              }
              if (retValue.returnObject !== 1) {
                retValue.hasError = true;
                retValue.message = "修改用户信息出错，影响行(" + retValue.returnObject + ")";
                callback(retValue);
                return;
              }
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "修改用户信息成功"});
        });
      },
      Page: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-info/page?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&type=user.user-info.page&Cache=true&P_Get=true&P_Total=0&iDisplayStart=0&iDisplayLength=6&Sort_Col=Coin_Total
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //分页查询
          function (callback) {
            var reqModel = CommonUtils.Common.AjaxPage.Request(req);
            //查询参数
            var reqParm = new DALFactory.User.Page.UserInfo_Parm();
            if (reqModel.Filter_Value.length > 0) {
              switch (reqModel.Filter_Type) {
                case "Phone":
                  reqParm.Phone = reqModel.Filter_Value;
                  break;
                case "Email":
                  reqParm.Email = reqModel.Filter_Value;
                  break;
                case "NickName":
                  reqParm.NickName = reqModel.Filter_Value;
                  break;
                default:
                  reqParm.FuzzyQuery = reqModel.Filter_Value;
                  break;
              }
            }
            reqParm.Sex = KOC.StringUtils.ToInt(req.params.Sex);
            reqParm.IsAnchor = KOC.StringUtils.ToInt(req.params.IsAnchor, -1);
            reqParm.IsFamily = KOC.StringUtils.ToInt(req.params.IsFamily, -1);
            reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.Family_ID, -1);
            reqParm.Status = req.params.F_Status || reqParm.Status;
            //排序
            switch (reqModel.Sort_Col) {
              case "User_ID":
              case "EXP":
              case "VIP":
              case "VIP_Expire":
              case "Coin":
              case "Coin_Today":
              case "Coin_Week":
              case "Coin_Month":
              case "Coin_Year":
              case "Coin_Total":
              case "Fans":
              case "Attention":
              case "Login_Count":
              case "Login_This_Date":
                break;
              case "Family_ID":
                break;
              default:
                reqModel.Sort_Col = "`User_ID`";
                break;
            }
            DALFactory.User.Page.UserInfo(reqParm, reqModel, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              _Value.PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
              KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                _Value.PageData.aaData.push({
                  User_ID: ThisValue.User_ID,
                  NickName: ThisValue.NickName,
                  QQ: ThisValue.QQ,
                  Sex: ThisValue.Sex,
                  Birthday: ThisValue.Birthday,
                  Constellation: ThisValue.Constellation,
                  EXP: ThisValue.EXP,
                  Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
                  VIP: ThisValue.VIP && (!ThisValue.VIP_Expire || KOC.Moment().isBefore(retValue.returnObject.VIP_Expire)),
                  VIP_Expire: ThisValue.VIP_Expire,
                  Coin_Today: ThisValue.Coin_Today,
                  Coin_Week: ThisValue.Coin_Week,
                  Coin_Month: ThisValue.Coin_Month,
                  Coin_Year: ThisValue.Coin_Year,
                  Coin_Total: ThisValue.Coin_Total,
                  Beans: ThisValue.Beans,
                  Beans_Today: ThisValue.Beans_Today,
                  Beans_Week: ThisValue.Beans_Week,
                  Beans_Month: ThisValue.Beans_Month,
                  Beans_Year: ThisValue.Beans_Year,
                  Beans_Total: ThisValue.Beans_Total,
                  Fans: ThisValue.Fans,
                  Attention: ThisValue.Attention,
                  IsAnchor: ThisValue.IsAnchor,
                  IsFamily: ThisValue.IsFamily,
                  Login_Count: ThisValue.Login_Count,
                  Login_This_Date: ThisValue.Login_This_Date,
                  Create_Date: ThisValue.Create_Date,
                  RoomName: ThisValue.RoomName,
                  RoomWelcome: ThisValue.RoomWelcome,
                  Tags: ThisValue.Tags,
                  Live: ThisValue.Live,
                  Live_StartTime: ThisValue.Live_StartTime,
                  Live_Order_No: ThisValue.Live_Order_No,
                  Live_Duration_Total: ThisValue.Live_Duration_Total,
                  Anchor_Pomelo: ThisValue.Anchor_Pomelo,
                  Anchor_Pomelo_Today: ThisValue.Anchor_Pomelo_Today,
                  Anchor_Pomelo_Week: ThisValue.Anchor_Pomelo_Week,
                  Anchor_Pomelo_Month: ThisValue.Anchor_Pomelo_Month,
                  Anchor_Pomelo_Year: ThisValue.Anchor_Pomelo_Year,
                  Anchor_EXP: ThisValue.Anchor_EXP,
                  Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
                  Anchor_Create_Date: ThisValue.Anchor_Create_Date,
                  Anchor_Status: ThisValue.Anchor_Status,
                  Family_ID: ThisValue.Family_ID,
                  Family_Name: ThisValue.Family_Name,
                  Family_Create_Date: ThisValue.Family_Create_Date,
                  Live_Coin: ThisValue.Live_Coin,
                  Gift_Num: ThisValue.Gift_Num,
                  Gift_Num_Anchor: ThisValue.Gift_Num_Anchor,
                  Gift_Num_User: ThisValue.Gift_Num_User,
                  Gift_Count: ThisValue.Gift_Count,
                  Gift_Count_Anchor: ThisValue.Gift_Count_Anchor,
                  Gift_Count_User: ThisValue.Gift_Count_User,
                  Gift_Coin: ThisValue.Gift_Coin,
                  Gift_Coin_Anchor: ThisValue.Gift_Coin_Anchor,
                  Gift_Coin_User: ThisValue.Gift_Coin_User,
                  Gift_Pond_Count: ThisValue.Gift_Pond_Count,
                  Gift_Pond_Coin: ThisValue.Gift_Pond_Coin,
                  Guardian_Count: ThisValue.Guardian_Count,
                  Guardian_Coin: ThisValue.Guardian_Coin,
                  Live_Pomelo: ThisValue.Live_Pomelo,
                  Live_Duration: ThisValue.Live_Duration,
                  Live_Create_Date: ThisValue.Live_Create_Date,
                  Live_Status: ThisValue.Live_Status
                });
              });
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
            return;
          }
          res.jsonp({flag: 0, msg: "获取列表成功.", data: _Value.PageData});
        });
      },
      //region User_Attention:用户关注
      Attention: function (req, res) {
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          User_ID_Attention: req.params.User_ID_Attention,
          Cancel: req.params.Cancel//取消关注为true,关注不传
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //获取用户信息
          function (callback) {
            DALFactory.Business.User_Attention({
              User_ID: _Value.User_ID,
              User_ID_Attention: _Value.User_ID_Attention,
              Cancel: _Value.Cancel//取消关注为true,关注不传
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "用户关注成功"});
        });
      },
      //endregion
      //region Avatar:用户上传头像
      Avatar: function (req, res) {
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //上传头像
          function (callback) {
            FileBuilder.User.Avatar.Build(_Value.User_ID, FileBuilder.Common.TempFilePath(req.file.filename), function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //刷新cdn 头像dir
          function (callback) {
            Interface_QCloud.RefreshUrl(FileBuilder.User.Avatar.UrlAll(_Value.User_ID), function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            })
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "上传头像完成"});
        });
      },
      //endregion
      //region Share:用户分享成功赠送金币没人每天3次
      // 4d4f6edc21971fc521cc91e0a0d9968b
      Share: function (req, res) {
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          Share_Flag: req.params.Share_Flag,
          Count: 0
        };
        if (_Value.Share_Flag != 0) {
          res.jsonp({flag: 1, msg: "分享不成功，请重新分享！"});
          return;
        }
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //获取用户信息
          function (callback) {
            DALFactory.User.User_Info.Info(_Value.User_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (!retValue.returnObject) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.IsAnchor = retValue.returnObject.IsAnchor;
              // _Value.UserInfo = retValue.returnObject;
              _Value.Interface_Calls = retValue.returnObject.Interface_Calls;
              _Value.Interface_Date = retValue.returnObject.Interface_Date;
              callback();
            });
          },
          //更新用户金币
          function (callback) {
            var now = KOC.Moment();
            if (KOC.Moment(_Value.Interface_Date).isSame(now, 'day')) {
              if (_Value.Interface_Calls < 3) {
                _Value.Interface_Calls += 1;
              } else {
                res.jsonp({flag: 1, msg: "您今日分享次数已上限，请明天在来！"});
                return;
              }
            } else {
              _Value.Interface_Calls = 1;
            }
            console.log(_Value.Interface_Calls);

            DALFactory.User.User_Info.Update_Coin({
              User_ID: _Value.User_ID,
              Interface_Calls: _Value.Interface_Calls
            }, function (retValue) {
              if (retValue.hasError) {
                retValue.message = "修改用户金币信息出错";
                callback(retValue);
                return;
              }
              if (retValue.returnObject !== 1) {
                retValue.hasError = true;
                retValue.message = "修改用户金币信息出错，影响行(" + retValue.returnObject + ")";
                callback(retValue);
                return;
              }
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "恭喜您分享成功，获得金币5个！"});
        });
      }
      //endregion
    },
    //endregion
    //region User_Anchor:艺人
    User_Anchor: {
      //老版本的首页和排行榜，新版本只用做排行榜
      Page: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-anchor/page?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&type=user.user-anchor.page&Cache=true&P_Get=true&P_Total=0&iDisplayStart=0&iDisplayLength=6&Sort_Col=Beans_Total
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //分页查询
          function (callback) {
            var reqModel = CommonUtils.Common.AjaxPage.Request(req);
            //查询参数
            var reqParm = new DALFactory.User.Page.UserAnchor_Parm();
            reqParm.Sex = req.params.F_Sex ? KOC.StringUtils.ToInt(req.params.F_Sex) : reqParm.Sex;
            reqParm.IsFamily = req.params.F_IsFamily ? KOC.StringUtils.ToInt(req.params.F_IsFamily, -1) : reqParm.IsFamily;
            reqParm.Family_ID = req.params.F_Family_ID ? KOC.StringUtils.ToInt(req.params.F_Family_ID, -1) : reqParm.Family_ID;
            reqParm.Tags = req.params.F_Tags ? req.params.F_Tags : reqParm.Tags;
            reqParm.Live = KOC.StringUtils.ToInt(req.params.F_Live, -1) >= 0 ? KOC.StringUtils.ToInt(req.params.F_Live) : reqParm.Live;
            reqParm.Status = "0";
            if (reqModel.Filter_Value.length > 0) {
              switch (reqModel.Filter_Type) {
                case "User_ID":
                  reqParm.User_ID = reqModel.Filter_Value;
                  break;
                case "Family_ID":
                  reqParm.Family_ID = reqModel.Filter_Value;
                  break;
                case "Phone":
                  reqParm.Phone = reqModel.Filter_Value;
                  break;
                case "Email":
                  reqParm.Email = reqModel.Filter_Value;
                  break;
                case "NickName":
                  reqParm.NickName = reqModel.Filter_Value;
                  break;
                case "RoomName":
                  reqParm.RoomName = reqModel.Filter_Value;
                  break;
                case "Tags":
                  reqParm.Tags = reqModel.Filter_Value;
                  break;
                default:
                  reqParm.FuzzyQuery = reqModel.Filter_Value;
                  break;
              }
            }
            //排序
            switch (reqModel.Sort_Col) {
              case "User_ID":
              case "EXP":
              case "Anchor_EXP":
              case "Beans":
                reqModel.Sort_Col = "`Beans_Total`";
                break;
              case "Beans_Today":
              case "Beans_Week":
              case "Beans_Month":
              case "Beans_Year":
              case "Beans_Total":
              case "Fans":
              case "Attention":
              case "Login_This_Date":
              case "Anchor_Pomelo":
              case "Anchor_Pomelo_Today":
              case "Anchor_Pomelo_Week":
              case "Anchor_Pomelo_Month":
              case "Anchor_Pomelo_Year":
              case "HotValue":
              case "Anchor_Status":
              case "Family_ID":
                break;
              case "Create_Date":
                reqModel.Sort_Col = "`User_ID`";
                break;
              case "Anchor_Create_Date":
                reqModel.Sort_Col = "`Create_Date`";
                break;
              case "Anchor_Pomelo_Total":
                reqModel.Sort_Col = "`Anchor_Pomelo`";
                break;
              default:
                reqModel.Sort_Col = "`Live` DESC, `Live_Stream_Status` DESC, `HotValue` DESC, `Beans_Today` DESC";
                reqModel.Sort_Dir = "";
                break;
            }
            DALFactory.User.Page.UserAnchor(reqParm, reqModel, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              _Value.PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
              KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                _Value.PageData.aaData.push({
                  User_ID: ThisValue.User_ID,
                  NickName: ThisValue.NickName,
                  RoomName: ThisValue.RoomName,
                  RoomWelcome: ThisValue.RoomWelcome,
                  RoomTemplate: ThisValue.RoomTemplate,
                  RoomTitle: ThisValue.RoomTitle,
                  RoomNotice: ThisValue.RoomNotice,
                  Family_ID: ThisValue.Family_ID,
                  Family_Name: ThisValue.Family_Name,
                  Family_UserID: ThisValue.Family_UserID,
                  Sex: ThisValue.Sex,
                  EXP: ThisValue.EXP,
                  HotValue_Ranking: ThisValue.HotValue_Ranking,
                  HotValue: ThisValue.HotValue,
                  ActivityNum: ThisValue.ActivityNum,
                  Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
                  Beans: ThisValue.Beans,
                  Beans_Today: ThisValue.Beans_Today,
                  Beans_Week: ThisValue.Beans_Week,
                  Beans_Month: ThisValue.Beans_Month,
                  Beans_Year: ThisValue.Beans_Year,
                  Beans_Total: ThisValue.Beans_Total,
                  Fans: ThisValue.Fans,
                  Attention: ThisValue.Attention,
                  IsFamily: ThisValue.IsFamily,
                  Tags: ThisValue.Tags ? ThisValue.Tags.split(",") : null,
                  Live: ThisValue.Live,
                  Live_StartTime: ThisValue.Live_StartTime,
                  Live_Order_No: ThisValue.Live_Order_No,
                  Live_Duration_Total: ThisValue.Live_Duration_Total,
                  Live_IsMobile: ThisValue.Live_IsMobile,
                  Live_Mode: ThisValue.Live_Mode,
                  Live_Stream_LastDate: ThisValue.Live_Stream_LastDate,
                  Live_Stream_Status: ThisValue.Live_Stream_Status,
                  IsWeekStar: ThisValue.IsWeekStar,
                  IsRecommend: ThisValue.IsRecommend,
                  ProtectDue_Date: ThisValue.ProtectDue_Date,
                  Rating: ThisValue.Rating,
                  Score: ThisValue.Score,
                  Integral: ThisValue.Integral,
                  Integral_Month: ThisValue.Integral_Month,
                  Integral_Month_Last: ThisValue.Integral_Month_Last,
                  Integral_Week: ThisValue.Integral_Week,
                  Integral_Week_Last: ThisValue.Integral_Week_Last,
                  Integral_Date: ThisValue.Integral_Date,
                  Anchor_Pomelo: ThisValue.Anchor_Pomelo,
                  Anchor_Pomelo_Today: ThisValue.Anchor_Pomelo_Today,
                  Anchor_Pomelo_Week: ThisValue.Anchor_Pomelo_Week,
                  Anchor_Pomelo_Month: ThisValue.Anchor_Pomelo_Month,
                  Anchor_Pomelo_Year: ThisValue.Anchor_Pomelo_Year,
                  Anchor_Pomelo_Total: ThisValue.Anchor_Pomelo,
                  Anchor_EXP: ThisValue.Anchor_EXP,
                  Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
                  ApplyMoney_LastDate: ThisValue.ApplyMoney_LastDate,
                  Create_Date: ThisValue.Create_Date,
                  Anchor_Create_Date: ThisValue.Create_Date,
                  Status: ThisValue.Status,
                  Anchor_Status: ThisValue.Status
                });
              });
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
            return;
          }
          res.jsonp(_Value.PageData);
        });
      },
      //首页艺人热度列表
      ListHot: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-anchor/listhot?Start=0&Length=6
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          Start: KOC.StringUtils.ToInt(req.params.Start, -1) > 0 ? KOC.StringUtils.ToInt(req.params.Start, -1) : 0,//分页开始位置，默认0
          Length: KOC.StringUtils.ToInt(req.params.Length, -1) > 0 ? KOC.StringUtils.ToInt(req.params.Length, -1) : 20//分页长度,默认20
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //分页查询
          function (callback) {
            DALFactory.RedisCommon.UserAnchorListHot.Get(_Value.Start, _Value.Length, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              _Value.List = retValue.returnObject;
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
            return;
          }
          res.jsonp({flag: 0, msg: "", data: _Value.List});
        });
      },
      //艺人搜索列表
      ListAnchorSearch: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-anchor/listanchorsearch?SearchValue="艺人"
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          IsSearch: req.params.IsSearch,//是否需要查询
          SearchValue: req.params.SearchValue,//查询信息
          Limit: req.params.Limit,//默认50条
          IsHotList: req.params.IsHotList,//是否需要热门列表,类型Bool,默认需要
          HotLimit: req.params.HotLimit //默认5条
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //获取艺人搜索列表
          function (callback) {
            DALFactory.Business.User_AnchorSearch({
              IsSearch: _Value.IsSearch,
              SearchValue: _Value.SearchValue,
              Limit: _Value.Limit,
              IsHotList: _Value.IsHotList,
              HotLimit: _Value.HotLimit
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              _Value.RetData = {
                IsSearch: retValue.returnObject.IsSearch,
                SearchValue: retValue.returnObject.SearchValue,
                Limit: retValue.returnObject.Limit,
                IsHotList: retValue.returnObject.IsHotList,
                HotLimit: retValue.returnObject.HotLimit,
                AnchorList: retValue.returnObject.AnchorList,
                AnchorHotList: retValue.returnObject.AnchorHotList
              };
              callback();
            });
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
            return;
          }
          res.jsonp({flag: 0, msg: "", data: _Value.RetData});
        });
      },
      //艺人申请入驻
      ApplyEnter: function (req, res) {
        //http://127.0.0.1:2003/mobile/user/user-anchor/applyenter?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&RealName=张三
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          Sex: req.params.Sex,
          RealName: req.params.RealName,
          Phone: req.params.Phone,
          QQ: req.params.QQ,
          Email: req.params.Email,
          Tags: req.params.Tags,
          Network: req.params.Network,
          Family_ID: req.params.Family_ID,

          Account_RealName: req.params.Account_RealName,
          Account_CardNo: req.params.Account_CardNo,
          Account_BankFullName: req.params.Account_BankFullName,
          Account_Province: req.params.Account_Province,
          Account_City: req.params.Account_City,
          Account_BankName: req.params.Account_BankName,
          IDCard: req.params.IDCard
        };
        if (!_Value.Phone) {
          res.jsonp({flag: 1, msg: "请输入手机号"});
          return;
        }
        if (!(/^0?(13[0-9]|15[012356789]|18[0123456789]|17[0123456789]|14[57])[0-9]{8}$|^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/).test(_Value.Phone)) {
          res.jsonp({flag: 1, msg: "你输入的手机号格式不正确"});
          return;
        }
        if (!_Value.Email) {
          res.jsonp({flag: 1, msg: "请输入email"});
          return;
        }
        if (!(/^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/).test(_Value.Email)) {
          res.jsonp({flag: 1, msg: "你输入的email格式不正确"});
          return;
        }
        if (!_Value.RealName) {
          res.jsonp({flag: 1, msg: "请输入真实姓名"});
          return;
        }
        if (!_Value.QQ) {
          res.jsonp({flag: 1, msg: "请输入QQ号"});
          return;
        }

        if (!_Value.Account_RealName) {
          res.jsonp({flag: 1, msg: "请输入开户行姓名"});
          return;
        }
        if (!_Value.Account_CardNo) {
          res.jsonp({flag: 1, msg: "请输入开户行账号"});
          return;
        }
        if (!_Value.Account_BankFullName) {
          res.jsonp({flag: 1, msg: "请选择开户行"});
          return;
        }
        if (!_Value.Account_Province) {
          res.jsonp({flag: 1, msg: "请选择省份"});
          return;
        }
        if (!_Value.Account_City) {
          res.jsonp({flag: 1, msg: "请选择市"});
          return;
        }
        if (!_Value.Account_BankName) {
          res.jsonp({flag: 1, msg: "请输入开户行地址及分行名称"});
          return;
        }
        if (!_Value.IDCard) {
          res.jsonp({flag: 1, msg: "请输入身份证号"});
          return;
        }
        if (!(/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(_Value.IDCard))) {
          res.jsonp({flag: 1, msg: "身份证格式不正确"});
          return;
        }

        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //获取工会信息列表
          function (callback) {
            if (!req.params.Family_ID) {
              callback();
              return;
            }
            DALFactory.User.Family_Info.Info(_Value.Family_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (!retValue.returnObject) {
                retValue.errorCode = -2;
                retValue.message = "没有相应的公会，请重新输入";
                callback(retValue);
                return;
              }
              _Value.Family_ID = retValue.returnObject.Family_ID;
              _Value.Family_Name = retValue.returnObject.Family_Name;
              callback();
            });
          },
          //写入redis StepOne
          function (callback) {
            DALFactory.RedisCommon.UserAnchorApply.StepOne({
              User_ID: _Value.User_ID,
              Sex: _Value.Sex,
              RealName: _Value.RealName,
              Phone: _Value.Phone,
              QQ: _Value.QQ,
              Email: _Value.Email,
              Tags: _Value.Tags,
              Network: _Value.Network,
              Family_ID: _Value.Family_ID
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //验证身份证
          function (callback) {
            DALFactory.User.User_Anchor.Info_IDCard(_Value.IDCard, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (retValue.returnObject) {
                retValue.errorCode = 1;
                retValue.message = '身份证号重复，请重新填写';
                callback(retValue);
                return;
              }
              callback();
            })
          },
          //写入redis StepTwo
          function (callback) {
            DALFactory.RedisCommon.UserAnchorApply.StepTwo({
              User_ID: _Value.User_ID,
              Account_RealName: _Value.Account_RealName,
              Account_CardNo: _Value.Account_CardNo,
              Account_BankFullName: _Value.Account_BankFullName,
              Account_Province: _Value.Account_Province,
              Account_City: _Value.Account_City,
              Account_BankName: _Value.Account_BankName,
              IDCard: _Value.IDCard
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          // StepThree
          function (callback) {
            DALFactory.Business.User_AnchorApply({
              User_ID: _Value.User_ID,
              Create_IP: KOC.StringUtils.GetClientIP(req)
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            })
          }
        ], function (retValue) {
          if (retValue.hasError) {
            res.jsonp({
              flag: retValue.errorCode,
              msg: retValue.message
            });
            return;
          }
          res.jsonp({flag: 0, msg: "申请完成,请等待管理员审核"});
        });
      },
      //艺人上传身份证
      User_AnchorIDCard: function (req, res) {
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign,
          Front: KOC.StringUtils.ToString(req.params.Front)
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //读取艺人信息
          function (callback) {
            DALFactory.User.User_Anchor.Info(_Value.User_ID, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              if (retValue.returnObject && retValue.returnObject.Status != 3 && retValue.returnObject.Status != 0) {
                callback(KOC.ReturnValue.New({
                  hasError: true,
                  errorCode: 2,
                  message: "艺人信息已锁定或正在审批中不能上传身份证图片"
                }));
                return;
              }
              callback();
            });
          },
          // 上传身份证
          function (callback) {
            FileBuilder.User.IDCard.Build(_Value.User_ID, _Value.Front, FileBuilder.Common.TempFilePath(req.file.filename), function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          },
          //刷新cdn 艺人封面dir
          function (callback) {
            Interface_QCloud.RefreshUrl(FileBuilder.User.IDCard.UrlAll(_Value.User_ID, "idcard-" + _Value.Front), function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            })
          }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "上传身份证图片完成"});
        });
      },
      //艺人上传封面
      Cover: function (req, res) {
        var _Value = {
          Mobile_ID: req.params.mid,
          APP_Type: req.params.app_t,
          Sign: req.params.sign
        };
        KOC.Async.series([
          //验证签名串
          function (callback) {
            DALFactory.Business.User_MobileAuthVerify({
              Mobile_ID: _Value.Mobile_ID,
              APP_Type: _Value.APP_Type,
              Sign: _Value.Sign
            }, function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              //登录验证
              if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
                retValue.hasError = true;
                retValue.message = "用户未登录，请先登录";
                callback(retValue);
                return;
              }
              _Value.User_ID = retValue.returnObject.User_ID;
              callback();
            });
          },
          //上传封面
          function (callback) {
            FileBuilder.User.Cover.Build(_Value.User_ID, FileBuilder.Common.TempFilePath(req.file.filename), function (retValue) {
              if (retValue.hasError) {
                callback(retValue);
                return;
              }
              callback();
            });
          }
          //刷新cdn 艺人封面dir
          // function (callback) {
          //     Interface_QCloud.RefreshDir(FileBuilder.User.Url(_Value.User_ID, "cover"), function (retValue) {
          //         if (retValue.hasError) {
          //             callback(retValue);
          //             return;
          //         }
          //         callback();
          //     })
          // }
        ], function (retValue) {
          if (retValue) {
            res.jsonp({flag: retValue.errorCode, msg: retValue.message});
            return;
          }
          res.jsonp({flag: 0, msg: "上传封面完成"});
        });
      }
    }
    //endregion
  },
  //endregion
  //region PhoneVerifyCode:手机注册-获取手机验证码
  PhoneVerifyCode: function (req, res) {
    // http://127.0.0.1:2003/mobile/phoneverifycode?mid=1&app_t=100&lname=13655548845&lpw=e63b58&sign=e63b&Phone=18410077168
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      Phone: req.params.Phone,
      News: ''
    };
    _Value.Phone = KOC.StringUtils.ToInt(_Value.Phone, -1);
    if (_Value.Phone < 0 || !(/^1\d{10}$/).test(_Value.Phone)) {
      res.jsonp({flag: 1, msg: "请输入正确的手机号"});
      return;
    }
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          callback();
        });
      },
      //发送手机验证码
      function (callback) {
        DALFactory.RedisCommon.PhoneAuthCode.Get(_Value.Phone, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          Interface_QCloud_SMS.SendSMS_VerifyCode(_Value.Phone, retValue.returnObject.Code, function (retValue) {
            if (retValue.hasError) {
              callback(retValue);
              return;
            }
            callback();
          });
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "发送手机验证码成功"});
    });
  },
  //endregion
  //region Pay_Order:充值，下订单
  Pay_Order: function (req, res) {
    //http://127.0.0.1:2003/mobile/pay-order?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&pay_type=12&pay_amt=13&pay_code=null
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      pay_type: req.params.pay_type,
      pay_amt: req.params.pay_amt,
      pay_code: req.params.pay_code
    };
    if (!_Value.pay_type) {
      res.jsonp({flag: 1, msg: "pay_type:请选择支付类型"});
      return;
    }
    if (!_Value.pay_amt) {
      res.jsonp({flag: 1, msg: "请输入支付金额或输入支付金额"});
      return;
    }
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          callback();
        });
      },
      //插入支付数据
      function (callback) {
        DALFactory.Business.User_PayOrder({
          User_ID: _Value.User_ID,
          Pay_Type: _Value.pay_type,
          Pay_Style: _Value.pay_code,
          Pay_From: 1,
          Pay_Money: _Value.pay_amt,
          Create_IP: KOC.StringUtils.GetClientIP(req)
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          _Value.pay_code = retValue.returnObject.Pay_Style;
          _Value.ordercode = retValue.returnObject.Order_No;
          _Value.IP = retValue.returnObject.Create_IP;
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      var date = KOC.Moment().format("YYYYMMDDhhmmss");
      var _signString = KOC.StringUtils.MD5(
        "version=" + Config.Interface.Heepay.APP.Version +
        "&agent_id=" + Config.Interface.Heepay.APP.AgentID +
        "&agent_bill_id=" + _Value.ordercode +
        "&agent_bill_time=" + date +
        "&pay_type=" + _Value.pay_type +
        "&pay_amt=" + _Value.pay_amt +
        "&notify_url=" + Config.Common.Virtual_Path.Main + "heepay/business.user-paymobile" +
        "&user_ip=" + _Value.IP +
        "&key=" + Config.Interface.Heepay.APP.Key
      );
      var data = {
        agent_bill_id: _Value.ordercode,
        return_url: Config.Common.Virtual_Path.Main + "member/user",
        notify_url: Config.Common.Virtual_Path.Main + "heepay/business.user-paymobile",
        user_ip: _Value.IP,
        agent_bill_time: date,
        goods_name: "QuanMinXiuTV",
        remark: "QuanMinXiuTV",
        sign: _signString,
        agentid: Config.Interface.Heepay.APP.AgentID,
        version: Config.Interface.Heepay.APP.Version
      };
      res.jsonp({flag: 0, msg: "用户下订单成功", data: data});
    });
  },
  //endregion
  //region IOS_Pay_Order:苹果充值，下订单
  IOS_Pay_Order: function (req, res) {
    //http://127.0.0.1:2003/mobile/pay-order?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&pay_type=12&pay_amt=13&pay_code=null
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      pay_type: 100,
      pay_amt: req.params.pay_amt,
      pay_code: 100
    };
    if (!_Value.pay_amt) {
      res.jsonp({flag: 1, msg: "请输入支付金额或输入支付金额"});
      return;
    }
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          callback();
        });
      },
      //插入支付数据
      function (callback) {
        DALFactory.Business.User_PayOrder({
          User_ID: _Value.User_ID,
          Pay_Type: _Value.APP_Type,
          Pay_Style: _Value.pay_code,
          Pay_From: 2,
          Pay_Money: parseInt(_Value.pay_amt),
          Create_IP: KOC.StringUtils.GetClientIP(req)
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          _Value.Order_No = retValue.returnObject.Order_No;
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "用户下订单成功", pay_amt: _Value.pay_amt, Order_No: _Value.Order_No});
    });
  },
  //endregion
  //region Apple_Pay:苹果充值成功
  Apple_Pay: function (req, res) {
    //http://127.0.0.1:2003/mobile/apple_pay?mid=1&app_t=100&sign=e63b52499b0423597e001c829f4dbe58&pay_type=12&pay_amt=13&pay_code=null
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      Order_No: req.params.Order_No,
      receiptdata: req.params.receiptdata,
    };
    if (!_Value.receiptdata || !_Value.Order_No) {
      res.jsonp({flag: 1, msg: "参数错误"});
      return;
    }
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          callback();
        });
      },
      //apple 二次验证
      function (callback) {
        Interface_apple.Send(_Value.receiptdata, _Value.User_ID, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          if (retValue.returnObject.Status != 0) {
            retValue.hasError = true;
            retValue.errorCode = retValue.returnObject.Status;
            retValue.message = "验证失败";
            callback(retValue);
            return;
          }
          _Value.Status = retValue.returnObject.Status;
          _Value.Quantity = retValue.returnObject.Quantity;
          _Value.Pay_Money = KOC.StringUtils.ToInt(retValue.returnObject.Pay_Money);
          _Value.Pay_TransNumber = retValue.returnObject.Pay_TransNumber;
          callback();
        });
      },
      //apple 修改数据库
      function (callback) {
        //插入支付数据
        DALFactory.Business.User_PayMoney({
          Pay_Money: _Value.Pay_Money,
          Order_No: _Value.Order_No,
          Pay_TransNumber: _Value.Pay_TransNumber,
          Create_IP: KOC.StringUtils.GetClientIP(req)
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message, Order_No: _Value.Order_No});
        return;
      }
      res.jsonp({flag: 0, msg: "充值成功", Order_No: _Value.Order_No});
    });
  },
  //endregion
  //region Banner:轮播图列表
  Banner: function (req, res) {
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    console.log('----111', Config.Common.Virtual_Path.Main);
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          _Value.APP_Version = retValue.returnObject.APP_Version;
          callback();
        });
      },
      //获取轮播图图片(老版本)
      function (callback) {
        if (_Value.APP_Version >= "3") {
          callback();
          return;
        }
        _Value.ImageUrl = [
          //首冲活动活动
          {
            Image: Config.Common.Virtual_Path.Static + "main/image/activity/2016/banner/expect.jpg",//"http://static.x.xiutv.com/main/image/activity/2016/yzdcg/firstpay.png",
            Url: Config.Common.Virtual_Path.Static + "main/image/activity/2016/banner/expect.jpg"
          },
          {
            Image: "http://cdn.cos.xiutv.com/image/activity/2016/banner/m-v-firstpay.png",//"http://static.x.xiutv.com/main/image/activity/2016/yzdcg/firstpay.png",
            Url: Config.Common.Virtual_Path.Main + "activity/2016/firstpay/m"
          }
          //艺人招募令
          // {
          //   Image: "http://cdn.cos.xiutv.com/image/activity/2016/banner/m-v-anchor-join.png",
          //   Url: "http://mp.weixin.qq.com/s?__biz=MzAxNzcxMjk4Ng==&mid=100000002&idx=1&sn=8a0d405de99dd8e8f3a1e3e2291a6a54&scene=18#wechat_redirect"
          // }
        ];
        callback();
      },
      //获取轮播图图片(新版本)
      function (callback) {
        if (_Value.APP_Version < "3") {
          callback();
          return;
        }
        _Value.ImageUrl = [
          // //首冲活动活动
          {
            Image: Config.Common.Virtual_Path.Static + "main/image/activity/2016/banner/expect.jpg",//"http://static.x.xiutv.com/main/image/activity/2016/yzdcg/firstpay.png",
            Url: Config.Common.Virtual_Path.Static + "main/image/activity/2016/banner/expect.jpg"
          },
          {
            Image: "http://cdn.cos.xiutv.com/image/activity/2016/banner/m-h-firstpay.png",//"http://static.x.xiutv.com/main/image/activity/2016/yzdcg/firstpay.png",
            Url: Config.Common.Virtual_Path.Main + "activity/2016/firstpay/m"
          }
          //艺人招募令
          // {
          //   Image: "http://cdn.cos.xiutv.com/image/activity/2016/banner/m-h-anchor-join.png",
          //   Url: "http://mp.weixin.qq.com/s?__biz=MzAxNzcxMjk4Ng==&mid=100000002&idx=1&sn=8a0d405de99dd8e8f3a1e3e2291a6a54&scene=18#wechat_redirect"
          // }
        ];
        callback();
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "获取轮播图列表成功.", data: _Value.ImageUrl});
    });
  },
  //endregion
  //region GiftList:礼物列表
  GiftList: function (req, res) {
    //http://127.0.0.1:2003/mobile/giftlist
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    _Value.Gift_Info = CommonUtils.Commodity.Gift.Data;//获取礼物列表
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.APP_Version = retValue.returnObject.APP_Version;
          callback();
        });
      },
      //获取旧版本礼物列表
      function (callback) {
        if ((_Value.APP_Type == 300 && _Value.APP_Version > '2.0.1') || (_Value.APP_Type == 100 && _Value.APP_Version > '2.0.2')) {
          callback();
          return;
        }
        var list = _Value.Gift_Info;
        _Value.list = [];
        if (_Value.APP_Type == 300) {
          //IOS
          for (var i in list) {
            var Gift = list[i];
            if (!Gift.Status) {
              if (Gift.id == 44) {
                Gift.Tag = KOC.Lodash.drop(Gift.Tag);
                Gift.RoomTemplate.push("IMax2");
              }
              _Value.list.push(Gift);
            }
          }
        } else {
          //安卓
          for (var i in list) {
            var Gift = list[i];
            if (!Gift.Status && (!list[i].PurchaseMode || list[i].PurchaseMode <= 1)) {
              _Value.list.push(Gift);
            }
          }
        }
        callback();
      },
      //获取礼物列表
      function (callback) {
        if ((_Value.APP_Type == 300 && _Value.APP_Version < '2.0.2') || (_Value.APP_Type == 100 && _Value.APP_Version < '2.0.3')) {
          callback();
          return;
        }
        var list = _Value.Gift_Info;
        _Value.list = [];
        for (var i in list) {
          if (!list[i].Status && (!list[i].PurchaseMode || list[i].PurchaseMode <= 1) && KOC.Lodash.includes(list[i].RoomTemplate, "IMax2")) {
            _Value.list.push(list[i]);
          }
        }
        callback();
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "获取礼物列表成功.", data: _Value.list});
    });
  },
  //endregion
  //region GuardianList:守护列表
  GuardianList: function (req, res) {
    //http://127.0.0.1:2003/mobile/weekstartrank?
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          callback();
        });
      },
      //获取守护列表
      function (callback) {
        _Value.list = CommonUtils.Commodity.Guardian.Data;
        callback();
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "获取守护列表成功.", data: _Value.list});
    });
  },
  //endregion
  //region WeekStarRank:周星榜列表
  WeekStarRank: function (req, res) {
    //http://127.0.0.1:2003/mobile/weekstartrank?Week=2
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      Week: req.params.Week, //请求类型：1-本周， 2-上周, 3-大上周， 4-大大上周， 5-特殊日期
      Gift_ID: req.params.Gift_ID,
      Length: req.params.Length,
      Type: req.params.Type,
      StartTime: req.params.StartTime,
      EndTime: req.params.EndTime
    };
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          callback();
        });
      },
      //获取当前版本号
      function (callback) {
        DALFactory.User.User_Mobile_APP.Info(_Value.Mobile_ID, _Value.APP_Type, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          if (!retValue.returnObject) {
            retValue.hasError = true;
            retValue.message = "未找到相关设备APP信息";
            callback(retValue);
            return;
          }
          _Value.APP_Type = retValue.returnObject.APP_Type;
          _Value.APP_Version = retValue.returnObject.APP_Version ? String(retValue.returnObject.APP_Version) : null;
          callback();
        });
      },
      //老版本单个榜单请求
      function (callback) {
        if ((_Value.APP_Type == 300 && _Value.APP_Version > '2.0.1') || (_Value.APP_Type == 100 && _Value.APP_Version > '2.0.2')) {
          callback();
          return;
        }
        DALFactory.Business.User_WeekStarRank({
          Gift_ID: _Value.Gift_ID,//礼物ID
          Length: _Value.Length,//请求个数
          Type: _Value.Type,//请求类型：1-艺人周星榜，2-粉丝周星榜
          Week: _Value.Week, //请求类型：1-本周， 2-上周, 3-大上周， 4-大大上周， 5-特殊日期
          StartTime: _Value.StartTime,
          EndTime: _Value.EndTime
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          _Value.list = retValue.returnObject;
          //返回
          callback();
        });
      },
      //获取周星榜列表
      function (callback) {
        if ((_Value.APP_Type == 300 && _Value.APP_Version < '2.0.2') || (_Value.APP_Type == 100 && _Value.APP_Version < '2.0.3')) {
          callback();
          return;
        }
        var GiftList = CommonUtils.Commodity.Gift.Data;
        _Value.list = [];
        _Value.WeekStart_GiftList = [];
        //获取本周周星礼物列表
        for (var index in GiftList) {
          if (GiftList[index].IsWeekStar && GiftList[index].Status == 0) {
            _Value.WeekStart_GiftList.push({
              Gift_ID: GiftList[index].id,
              Type: 1
            });
            _Value.WeekStart_GiftList.push({
              Gift_ID: GiftList[index].id,
              Type: 2
            });
          }
        }
        KOC.Async.each(_Value.WeekStart_GiftList, function (ThisValue, callback) {
          DALFactory.Business.User_WeekStarRank({
            Gift_ID: ThisValue.Gift_ID,//礼物ID
            Length: 3,//请求个数
            Type: ThisValue.Type,//请求类型：1-艺人周星榜，2-粉丝周星榜
            Week: _Value.Week, //请求类型：1-本周， 2-上周, 3-大上周， 4-大大上周， 5-特殊日期
            StartTime: _Value.StartTime,
            EndTime: _Value.EndTime
          }, function (retValue) {
            if (retValue.hasError) {
              callback(retValue);
              return;
            }
            _Value.list.push(retValue.returnObject);
            //返回
            callback();
          });
        }, function (retValue) {
          if (retValue) {
            callback(retValue);
            return;
          }
          callback();
        });

      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      res.jsonp({flag: 0, msg: "获取周星榜列表成功", data: _Value.list});
    });
  },
  //endregion
  //region ContributionList:贡献榜列表
  ContributionList: function (req, res) {
    //http://127.0.0.1:2003/mobile/contributionlist?TopN=20&User_ID=4605&OrderBy=Week
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign,
      TopN: req.params.TopN,
      OrderBy: req.params.OrderBy,
      User_ID: req.params.User_ID
    };
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          callback();
        });
      },
      //获取贡献榜列表列表
      function (callback) {
        DALFactory.User.User_Contribution.List({
          TopN: _Value.TopN,
          User_ID_Contribution: _Value.User_ID,
          OrderBy: _Value.OrderBy
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
            ThisValue.Level = CommonUtils.User.Level.fnLevel(ThisValue.EXP).Level;
          });
          _Value.List = retValue.returnObject;
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      //返回
      res.jsonp({flag: 0, msg: "获取贡献榜列表成功", data: _Value.List});
    });
  },
  //endregion
  //region AttentionList:关注列表
  AttentionList: function (req, res) {
    //http://127.0.0.1:2003/mobile/attentionlist?User_ID=5223&Cache=true&P_Get=true&P_Total=0&iDisplayStart=0&iDisplayLength=6&Sort_Col=Live_StartTime
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          callback();
        });
      },
      //获取关注列表
      function (callback) {
        var reqModel = CommonUtils.Common.AjaxPage.Request(req);
        //查询参数
        var reqParm = new DALFactory.User.Page.UserAttention_Parm();
        reqParm.User_ID = _Value.User_ID;
        //排序
        switch (reqModel.Sort_Col) {
          case "User_ID":
          case "EXP":
          case "VIP":
          case "VIP_Expire":
          case "Beans":
          case "Fans":
          case "Attention":
          case "Login_Count":
          case "Login_This_Date":
            break;
          case "User_Create_Date":
            reqModel.Sort_Col = "`User_ID`";
            break;
          case "Live":
          case "Live_StartTime":
          case "Live_Order_No":
          case "Live_Duration_Total":
          case "Anchor_Pomelo":
          case "Anchor_EXP":
          case "Anchor_Create_Date":
            break;
          case "Family_ID":
            break;
          default:
            reqModel.Sort_Col = "`Create_Date`";
            break;
        }
        DALFactory.User.Page.UserAttention(reqParm, reqModel, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          _Value.PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
          KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
            _Value.PageData.aaData.push({
              Create_Date: ThisValue.Create_Date,
              User_ID: ThisValue.User_ID,
              NickName: ThisValue.NickName,
              QQ: ThisValue.QQ,
              Sex: ThisValue.Sex,
              Birthday: ThisValue.Birthday,
              Constellation: ThisValue.Constellation,
              EXP: ThisValue.EXP,
              Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
              VIP: ThisValue.VIP && (!ThisValue.VIP_Expire || KOC.Moment().isBefore(retValue.returnObject.VIP_Expire)),
              VIP_Expire: ThisValue.VIP_Expire,
              Beans: ThisValue.Beans,
              Fans: ThisValue.Fans,
              Attention: ThisValue.Attention,
              IsAnchor: ThisValue.IsAnchor,
              IsFamily: ThisValue.IsFamily,
              Login_Count: ThisValue.Login_Count,
              Login_This_Date: ThisValue.Login_This_Date,
              User_Create_Date: ThisValue.User_Create_Date,
              RoomName: ThisValue.RoomName,
              RoomWelcome: ThisValue.RoomWelcome,
              Tags: ThisValue.Tags ? ThisValue.Tags.split(",") : null,
              Live: ThisValue.Live,
              Live_StartTime: ThisValue.Live_StartTime,
              Live_Order_No: ThisValue.Live_Order_No,
              Live_Duration_Total: ThisValue.Live_Duration_Total,
              Live_IsMobile: ThisValue.Live_IsMobile,
              Anchor_Pomelo: ThisValue.Anchor_Pomelo,
              Anchor_EXP: ThisValue.Anchor_EXP,
              Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
              Anchor_HotValue: ThisValue.Anchor_HotValue,
              Anchor_Create_Date: ThisValue.Anchor_Create_Date,
              Family_ID: ThisValue.Family_ID,
              Family_Name: ThisValue.Family_Name,
              Family_Create_Date: ThisValue.Family_Create_Date,
              Heat: ThisValue.Anchor_HotValue
            });
          });
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      //返回
      res.jsonp({flag: 0, msg: "获取关注列表成功", data: _Value.PageData});
    });
  },
  //endregion
  //region AnchorFansList:艺人的粉丝列表(移动端还没做这个功能，先给出接口)
  AnchorFansList: function (req, res) {
    //http://127.0.0.1:2003/mobile/anchorfanslist?User_ID=4605&Cache=true&P_Get=true&P_Total=0&iDisplayStart=0&iDisplayLength=6&Sort_Col=Live_StartTime
    var _Value = {
      Mobile_ID: req.params.mid,
      APP_Type: req.params.app_t,
      Sign: req.params.sign
    };
    KOC.Async.series([
      //验证签名串
      function (callback) {
        DALFactory.Business.User_MobileAuthVerify({
          Mobile_ID: _Value.Mobile_ID,
          APP_Type: _Value.APP_Type,
          Sign: _Value.Sign
        }, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          //登录验证
          if (!retValue.returnObject || (retValue.returnObject && retValue.returnObject.User_ID < 0)) {
            retValue.hasError = true;
            retValue.message = "用户未登录，请先登录";
            callback(retValue);
            return;
          }
          _Value.User_ID = retValue.returnObject.User_ID;
          callback();
        });
      },
      //获取粉丝列表
      function (callback) {
        var reqModel = CommonUtils.Common.AjaxPage.Request(req);
        //查询参数
        var reqParm = new DALFactory.User.Page.UserAnchorFans_Parm();
        reqParm.User_ID_Attention = _Value.User_ID;
        //排序
        switch (reqModel.Sort_Col) {
          case "User_ID":
          case "EXP":
          case "VIP":
          case "VIP_Expire":
          case "Beans":
          case "Fans":
          case "Attention":
          case "Login_Count":
          case "Login_This_Date":
          case "Create_Date":
            break;
          case "User_Create_Date":
            reqModel.Sort_Col = "`User_ID`";
            break;
          case "Live":
          case "Live_StartTime":
          case "Live_Order_No":
          case "Live_Duration_Total":
          case "Anchor_Pomelo":
          case "Anchor_EXP":
          case "Anchor_Create_Date":
            break;
          case "Family_ID":
            break;
          default:
            reqModel.Sort_Col = "`Create_Date`";
            break;
        }
        DALFactory.User.Page.UserAnchorFans(reqParm, reqModel, function (retValue) {
          if (retValue.hasError) {
            callback(retValue);
            return;
          }
          _Value.PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
          KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
            _Value.PageData.aaData.push({
              Create_Date: ThisValue.Create_Date,
              User_ID: ThisValue.User_ID,
              NickName: ThisValue.NickName,
              QQ: ThisValue.QQ,
              Sex: ThisValue.Sex,
              Birthday: ThisValue.Birthday,
              Constellation: ThisValue.Constellation,
              EXP: ThisValue.EXP,
              Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
              VIP: ThisValue.VIP && (!ThisValue.VIP_Expire || KOC.Moment().isBefore(retValue.returnObject.VIP_Expire)),
              VIP_Expire: ThisValue.VIP_Expire,
              Beans: ThisValue.Beans,
              Fans: ThisValue.Fans,
              Attention: ThisValue.Attention,
              IsAnchor: ThisValue.IsAnchor,
              IsFamily: ThisValue.IsFamily,
              Login_Count: ThisValue.Login_Count,
              Login_This_Date: ThisValue.Login_This_Date,
              User_Create_Date: ThisValue.User_Create_Date,
              RoomName: ThisValue.RoomName,
              RoomWelcome: ThisValue.RoomWelcome,
              Tags: ThisValue.Tags ? ThisValue.Tags.split(",") : null,
              Live: ThisValue.Live,
              Live_StartTime: ThisValue.Live_StartTime,
              Live_Order_No: ThisValue.Live_Order_No,
              Live_Duration_Total: ThisValue.Live_Duration_Total,
              Live_IsMobile: ThisValue.Live_IsMobile,
              Anchor_Pomelo: ThisValue.Anchor_Pomelo,
              Anchor_EXP: ThisValue.Anchor_EXP,
              Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
              Anchor_HotValue: ThisValue.Anchor_HotValue,
              Anchor_Create_Date: ThisValue.Anchor_Create_Date,
              Family_ID: ThisValue.Family_ID,
              Family_Name: ThisValue.Family_Name,
              Family_Create_Date: ThisValue.Family_Create_Date,
              Heat: ThisValue.Anchor_HotValue
            });
          });
          callback();
        });
      }
    ], function (retValue) {
      if (retValue) {
        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
        return;
      }
      //返回
      res.jsonp({flag: 0, msg: "获取艺人粉丝列表成功", data: _Value.PageData});
    });
  }
  //endregion

};